{template 'common/header'}
<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo $this->createWebUrl('mem')}">会员列表</a></li>
</ul>
{if $op == 'display'}
<style>
th{
	text-align: center !important;
}
td{
	text-align: center !important;
	white-space: normal !important;
	word-break: break-all !important;
}
</style>
<form action="" method="get" class="form-horizontal" role="form">
<div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="junsion_challeng" />
                <input type="hidden" name="do" value="mem" />
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
                    <div class="col-xs-12 col-sm-2 col-lg-2">
                        <input class="form-control" name="keyword" type="text" value="{$_GPC['keyword']}" placeholder="请输入会员昵称">
                    </div>
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
				    <div class="col-xs-12 col-sm-2 col-lg-2">
				        <select class="form-control" style="margin-right:15px;" name="status">
				            <option value="">全部</option>
				            <option value="0" {if empty($_GPC['status']) && $_GPC['status']!=''} selected="selected"{/if}>正常</option>
				            <option value="1" {if 1 == $_GPC['status']} selected="selected"{/if}>禁用</option>
				        </select>
				    </div>
                	<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
                    <div class=" col-xs-12 col-sm-3 col-lg-3">
                        <button class="btn btn-default" ><i class="fa fa-search"></i> 搜索</button>
                        {if $_W['isfounder']}
                        <a class="btn btn-primary" style='margin-left: 30px;' onclick="$('#modal-module-menus-pass').modal();">迁移数据</a>
                        {/if}
                   	</div>
                </div>
        </div>
    </div>
</form>
<div id="modal-module-menus-pass"  class="modal fade" tabindex="-1">
    <div class="modal-dialog" style='width: 520px;'>
        <div class="modal-content">
            <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>所有数据转移</h3></div>
            <div class="modal-body">
                <form action="{php echo $this->createWebUrl('trans')}" method="post"
                      class="form-horizontal  form-modal" onsubmit="return confirm('转移后目标小程序数据将被覆盖，确定转移吗？')">
                    <input type="hidden" name="rid" id="rid">
                    <div class="form-group" style="margin-bottom: 0px;">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">转移至 </label>
                        <div class="col-sm-9">
                            <select class="form-control" name="acc_id" style="margin-bottom: 20px;">
                            	{loop $accounts $a}
                            	<option value="{$a['uniacid']}">{$a['name']}</option>
                            	{/loop}
                            </select>
                            <span class="help-block" style="padding:0px;color:#f00;">转移目标小程序，必须拥有使用该模块的功能</span>
                            <span class="help-block" style="padding:0px;color:#f00;">转移目标小程序，必须接入同一个开放平台</span>
                            <span class="help-block" style="padding:0px;color:#f00;">转移目标小程序，原小程序所有数据皆会清除，被当前小程序所有数据覆盖</span>
                        </div>
                    </div>
                    <div class="form-group" style="text-align: center;margin-top: 20px;">
                         <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                         <button type="submit" style="margin-left: 50px;" class="btn btn-primary">提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
            	<th>会员昵称</th>
                <th>会员头像</th>
                <th>今日剩余<br/>挑战次数</th>
                <th>中奖次数<br/>总价值</th>
                <th>参与次数</th>
                <th>状态</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody id="mem-list">
            {loop $list $item}
            <tr>
            	<td>{$item['nickname']}</td>
                <td><img src="{php echo toimage($item['avatar'])}" style="width:60px;"></td>
                <td>{$item['challeng_num']}</td>
                <td>{$item['reward_num']}<br/>{$item['reward_price']}</td>
                <td>{$item['join_num']}</td>
                <td data-id='{$item["id"]}'>{if empty($item['status'])}<label class="label label-success">正常</label>{else}<label class="label label-default">禁用</label>{/if}</td>
               	<td>{php echo date('Y-m-d H:i',$item['createtime']);}</td>
               <td>
                   <a class="btn btn-danger btn-sm" onclick="return confirm('确认删除吗？');return false;" href="{php echo $this->createWebUrl('mem', array('op' => 'del', 'id' => $item['id']))}">删除</a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
 <script>
$('table label').click(function(){
	var label = $(this);
	$.ajax({
		url:"{php echo $this->createWebUrl('mem',array('op'=>'status'))}",
		type:'post',
		data:{id:label.parent().attr('data-id')},
		success:function(status){
			console.log(status);
			if(status == '1'){
				if(label.hasClass('label-success')){
					label.removeClass('label-success').addClass('label-default');
					label.text('禁用');
				}else{
					label.removeClass('label-default').addClass('label-success');
					label.text('正常');
				}
			}
		}
	});
});
</script>    
</div>
{/if}
